package com.meichis.yndms.vm;

import androidx.lifecycle.MutableLiveData;

import com.meichis.mcsappframework.utils.DateUtil;
import com.meichis.yndms.model.Notice;
import com.meichis.yndms.repository.manager.NoticeListManager;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2021-05-08 16:22
 */
public class NewExpressVM extends MyViewModel {

    private MutableLiveData<List<Notice>> noticeList;
    private MutableLiveData<List<Notice>> unReadNoticeList;
    private MutableLiveData<List<Notice>> readNoticeList;
    private MutableLiveData<Boolean> isRefresh;
    public boolean isReadPage = false;

    public MutableLiveData<Boolean> getIsRefresh() {
        if (isRefresh == null) {
            isRefresh = new MutableLiveData<>();
            isRefresh.setValue(false);
        }
        return isRefresh;
    }

    public MutableLiveData<List<Notice>> getUnReadNoticeList() {
        if (unReadNoticeList == null) {
            unReadNoticeList = new MutableLiveData<>();
            unReadNoticeList.setValue(new ArrayList<>());
        }
        return unReadNoticeList;
    }

    public MutableLiveData<List<Notice>> getReadNoticeList() {
        if (readNoticeList == null) {
            readNoticeList = new MutableLiveData<>();
            readNoticeList.setValue(new ArrayList<>());
        }
        return readNoticeList;
    }

    public MutableLiveData<List<Notice>> getNoticeList() {
        if (noticeList == null) {
            noticeList = new MutableLiveData<>();
        }
        return noticeList;
    }

    public void GetNewProductNotice() {
        NoticeListManager.getInstance().GetNotice(
                getShowDialog(), getUserInfo().getValue().getOrgId(),
                getUserInfo().getValue().getId(), DateUtil.getMultipleMonth(Calendar.getInstance().getTime(), -1, DateUtil.FORMAT_YMD),
                DateUtil.getCurDateStr(DateUtil.FORMAT_YMD),"新品速递" ,getNoticeList());
    }

    public void UpdateNoticeRead(String infoId) {
        NoticeListManager.getInstance().UpdateNoticeRead(
                getShowDialog(), getUserInfo().getValue().getOrgId(),
                getUserInfo().getValue().getId(), infoId, new MutableLiveData<>());
    }


}
